  <template> 
	<div class="JNPF-common-layout">
		<div class="JNPF-common-layout-center">
			<el-row class="JNPF-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="姓名">
							<el-input v-model="query.xm" placeholder="姓名" clearable  />
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="人员类型">
							<el-select v-model="query.rylx" placeholder="人员类型" clearable >
								<el-option v-for="(item, index) in rylxOptions" :key="index" :label="item.fullName" :value="item.id"  />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
					<el-form-item>
						<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
						<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
					</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<div class="JNPF-common-layout-main JNPF-flex-main">
				<div class="JNPF-common-head">
					<div>
						<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">
							新增
						</el-button>
						<el-button type="text" icon="el-icon-download" @click="exportData()">
							导出
						</el-button>
					</div>
					<div class="JNPF-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"  @click="reset()" />
						</el-tooltip>
						<screenfull :isContainer="true" />
						<el-tooltip effect="dark" content="列设置" placement="top">
							<el-link icon="icon-ym icon-ym-options JNPF-common-head-icon" :underline="false" />
						</el-tooltip>
					</div>
				</div>
				<JNPF-table v-loading="listLoading" :data="list">
					<el-table-column prop="xm" label="姓名" align="left" />
					<el-table-column label="性别"  prop="xb" algin="left">
						<template slot-scope="scope">{{ scope.row.xb | dynamicText(xbOptions) }}</template>
					</el-table-column>
					<el-table-column label="人员类型"  prop="rylx" algin="left">
						<template slot-scope="scope">{{ scope.row.rylx | dynamicText(rylxOptions) }}</template>
					</el-table-column>
					<el-table-column label="民族"  prop="mz" algin="left">
						<template slot-scope="scope">{{ scope.row.mz | dynamicText(mzOptions) }}</template>
					</el-table-column>
					<el-table-column prop="lxdh" label="联系电话" align="left" />
					<el-table-column prop="jkzk" label="健康状况" align="left" />
					<el-table-column prop="zgxl" label="最高学历" align="left" />
					<el-table-column prop="zy" label="专业" align="left" />
					<el-table-column prop="byyx" label="毕业院校" align="left" />
					<el-table-column label="证件类型"  prop="zjlx" algin="left">
						<template slot-scope="scope">{{ scope.row.zjlx | dynamicText(zjlxOptions) }}</template>
					</el-table-column>
					<el-table-column prop="zjhm" label="证件号码" align="left" />
					<el-table-column prop="cjgzsj" label="参加工作时间" align="left" />
					<el-table-column prop="yzbm" label="邮政编码" align="left" />
					<el-table-column prop="gzdw" label="工作单位" align="left" />
					<el-table-column prop="gzjl" label="工作简历" align="left" />
					<el-table-column prop="px" label="排序" align="left" />
					<!-- <el-table-column prop="zsyxqq" label="证书有效期起" align="left" />
					<el-table-column prop="zsyxqz" label="证书有效期止" align="left" /> -->
					<el-table-column label="操作" fixed="right" width="150">
						<template slot-scope="scope">
							<el-button type="text" @click="addOrUpdateHandle(scope.row.id)" >
								编辑
							</el-button>
							<el-button type="text" @click="handleDel(scope.row.id)" class="JNPF-table-delBtn">
								删除
							</el-button>
							<el-button type="text" @click="addOrUpdateHandle(scope.row.id,true)" >
								详情
							</el-button>
						</template>
					</el-table-column>
				</JNPF-table>
				<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
			</div>
		</div>
		<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
		<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
	</div>

</template> 
  <script>
    import request from '@/utils/request'
    import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
    import JNPFForm from './Form'
    import ExportBox from './ExportBox'
    import {previewDataInterface} from '@/api/systemData/dataInterface'

    export default {
        components: {JNPFForm, ExportBox},
        data() {
            return {
                    showAll: false,
                query: {
					xm:undefined,
					rylx:undefined,

                },
                defaultProps: {
                    children: 'children',
                    label: 'fullName'
                },
                list: [],
                listLoading: true,
                total: 0,
                listQuery: {
					currentPage: 1,
					pageSize: 20,

                    sort: "desc",
                    sidx: "",
                },
                formVisible: false,
                exportBoxVisible: false,
                columnList: [
					{prop: 'xm', label: '姓名'},
					{prop: 'xb', label: '性别'},
					{prop: 'rylx', label: '人员类型'},
					{prop: 'mz', label: '民族'},
					{prop: 'lxdh', label: '联系电话'},
					{prop: 'jkzk', label: '健康状况'},
					{prop: 'zgxl', label: '最高学历'},
					{prop: 'zy', label: '专业'},
					{prop: 'byyx', label: '毕业院校'},
					{prop: 'zjlx', label: '证件类型'},
					{prop: 'zjhm', label: '证件号码'},
					{prop: 'cjgzsj', label: '参加工作时间'},
					{prop: 'yzbm', label: '邮政编码'},
					{prop: 'gzdw', label: '工作单位'},
					{prop: 'gzjl', label: '工作简历'},
					{prop: 'px', label: '排序'},
					{prop: 'zsyxqq', label: '证书有效期起'},
					{prop: 'zsyxqz', label: '证书有效期止'},

                ],
				xbOptions:[{"fullName":"男","id":"1"},{"fullName":"女","id":"2"}],
				rylxOptions:[{"fullName":"分管领导","id":"1"},{"fullName":"带班领导","id":"2"},{"fullName":"安全总监","id":"3"},{"fullName":"安全管理部门负责人","id":"4"},{"fullName":"车间主任","id":"5"},{"fullName":"安全管理人员","id":"6"},{"fullName":"特种作业人员","id":"7"},{"fullName":"外来作业人员","id":"8"},{"fullName":"承包商","id":"9"}],
				// mzOptions:[{"fullName":"汉族","id":"1"},{"fullName":"回族","id":"2"},{"fullName":"维吾尔族","id":"3"},{"fullName":"藏族","id":"4"}],
				mzOptions:[],
				zjlxOptions:[{"fullName":"居民身份证","id":"1"},{"fullName":"军人证","id":"2"},{"fullName":"港澳台居民身份证","id":"3"},{"fullName":"华侨身份证","id":"4"},{"fullName":"外籍护照","id":"5"},{"fullName":"其他","id":"6"}],


            }
        },
        computed: {},
        created() {
			this.getmzOptions();
			this.initData();


        },
        methods: {
			getmzOptions(){
                // 获取民族
                this.$store.dispatch('base/getDictionaryData', { sort: 'Nation' }).then(res1 => {
                    this.mzOptions = res1
                })
            },

            initData() {
                this.listLoading = true;
                let query = {
                    ...this.listQuery,
                    ...this.query
                };
                request({
                    url: `/api/system/qyscXgry`,
                    method: 'get',
                    data: query
                }).then(res => {
                    this.list = res.data.list
                    this.total = res.data.pagination.total
                    this.listLoading = false
                    this.$nextTick(() => {
                        this.tableHeight = "100%"
                    });
                })
            },
            handleDel(id) {
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/system/qyscXgry/${id}`,
                        method: 'DELETE'
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => {
                });
            },
            addOrUpdateHandle(id,isDetail) {
                this.formVisible = true
                this.$nextTick(() => {
                    this.$refs.JNPFForm.init(id,isDetail)
                })
            },
            exportData() {
                this.exportBoxVisible = true
                this.$nextTick(() => {
                    this.$refs.ExportBox.init(this.columnList)
                })
            },
            download(data) {
                let query = {...data, ...this.listQuery, ...this.query}
                request({
                    url: `/api/system/qyscXgry/Actions/Export`,
                    method: 'POST',
                    data: query
                }).then(res => {
                    if (!res.data.url) return
                    window.location.href = this.define.comUrl + res.data.url
                    this.$refs.ExportBox.visible = false
                    this.exportBoxVisible = false
                })
            },
            search() {
                this.listQuery = {
					currentPage: 1,
					pageSize: 20,

                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            },
            refresh(isrRefresh) {
                this.formVisible = false
                if (isrRefresh) this.reset()
            },
            reset() {
                for (let key in this.query) {
                    this.query[key] = undefined
                }
                this.listQuery = {
					currentPage: 1,
					pageSize: 20,

                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            }
        }
    }
</script>